home *** CD-ROM | disk | FTP | other *** search
/ Delphi Magazine Collection 2001 / Delphi Magazine Collection 20001 (2001).iso / DISKS / Issue47 / Construc / TDM47Impl1.pas < prev    next >
Encoding:
Pascal/Delphi Source File  |  1999-06-04  |  8.8 KB  |  362 lines

  1. unit TDM47Impl1;
  2.  
  3. interface
  4.  
  5. uses
  6.   Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
  7.   ActiveX, AxCtrls, TDM47_TLB, ExtCtrls, DBCtrls, StdCtrls, Db, Mask,
  8.   DBTables;
  9.  
  10. type
  11.   TTDM47X = class(TActiveForm, ITDM47X)
  12.     TableBIOLIFE: TTable;
  13.     TableBIOLIFESpeciesNo: TFloatField;
  14.     TableBIOLIFECategory: TStringField;
  15.     TableBIOLIFECommon_Name: TStringField;
  16.     TableBIOLIFESpeciesName: TStringField;
  17.     TableBIOLIFELengthcm: TFloatField;
  18.     TableBIOLIFELength_In: TFloatField;
  19.     TableBIOLIFENotes: TMemoField;
  20.     TableBIOLIFEGraphic: TGraphicField;
  21.     Label1: TLabel;
  22.     DBEdit1: TDBEdit;
  23.     DataSource1: TDataSource;
  24.     Label2: TLabel;
  25.     DBEdit2: TDBEdit;
  26.     Label3: TLabel;
  27.     DBEdit3: TDBEdit;
  28.     Label4: TLabel;
  29.     DBEdit4: TDBEdit;
  30.     Label5: TLabel;
  31.     DBEdit5: TDBEdit;
  32.     Label6: TLabel;
  33.     DBEdit6: TDBEdit;
  34.     Label7: TLabel;
  35.     DBMemo1: TDBMemo;
  36.     DBImage1: TDBImage;
  37.     DBNavigator1: TDBNavigator;
  38.   private
  39.     { Private declarations }
  40.     FEvents: ITDM47XEvents;
  41.     procedure ActivateEvent(Sender: TObject);
  42.     procedure ClickEvent(Sender: TObject);
  43.     procedure CreateEvent(Sender: TObject);
  44.     procedure DblClickEvent(Sender: TObject);
  45.     procedure DeactivateEvent(Sender: TObject);
  46.     procedure DestroyEvent(Sender: TObject);
  47.     procedure KeyPressEvent(Sender: TObject; var Key: Char);
  48.     procedure PaintEvent(Sender: TObject);
  49.   protected
  50.     { Protected declarations }
  51.     procedure DefinePropertyPages(DefinePropertyPage: TDefinePropertyPage); override;
  52.     procedure EventSinkChanged(const EventSink: IUnknown); override;
  53.     function Get_Active: WordBool; safecall;
  54.     function Get_AutoScroll: WordBool; safecall;
  55.     function Get_AutoSize: WordBool; safecall;
  56.     function Get_AxBorderStyle: TxActiveFormBorderStyle; safecall;
  57.     function Get_BiDiMode: TxBiDiMode; safecall;
  58.     function Get_Caption: WideString; safecall;
  59.     function Get_Color: OLE_COLOR; safecall;
  60.     function Get_Cursor: Smallint; safecall;
  61.     function Get_DoubleBuffered: WordBool; safecall;
  62.     function Get_DropTarget: WordBool; safecall;
  63.     function Get_Enabled: WordBool; safecall;
  64.     function Get_Font: IFontDisp; safecall;
  65.     function Get_HelpFile: WideString; safecall;
  66.     function Get_KeyPreview: WordBool; safecall;
  67.     function Get_PixelsPerInch: Integer; safecall;
  68.     function Get_PrintScale: TxPrintScale; safecall;
  69.     function Get_Scaled: WordBool; safecall;
  70.     function Get_Visible: WordBool; safecall;
  71.     procedure _Set_Font(const Value: IFontDisp); safecall;
  72.     procedure Set_AutoScroll(Value: WordBool); safecall;
  73.     procedure Set_AutoSize(Value: WordBool); safecall;
  74.     procedure Set_AxBorderStyle(Value: TxActiveFormBorderStyle); safecall;
  75.     procedure Set_BiDiMode(Value: TxBiDiMode); safecall;
  76.     procedure Set_Caption(const Value: WideString); safecall;
  77.     procedure Set_Color(Value: OLE_COLOR); safecall;
  78.     procedure Set_Cursor(Value: Smallint); safecall;
  79.     procedure Set_DoubleBuffered(Value: WordBool); safecall;
  80.     procedure Set_DropTarget(Value: WordBool); safecall;
  81.     procedure Set_Enabled(Value: WordBool); safecall;
  82.     procedure Set_Font(var Value: IFontDisp); safecall;
  83.     procedure Set_HelpFile(const Value: WideString); safecall;
  84.     procedure Set_KeyPreview(Value: WordBool); safecall;
  85.     procedure Set_PixelsPerInch(Value: Integer); safecall;
  86.     procedure Set_PrintScale(Value: TxPrintScale); safecall;
  87.     procedure Set_Scaled(Value: WordBool); safecall;
  88.     procedure Set_Visible(Value: WordBool); safecall;
  89.   public
  90.     { Public declarations }
  91.     procedure Initialize; override;
  92.   end;
  93.  
  94. implementation
  95.  
  96. uses ComObj, ComServ;
  97.  
  98. {$R *.DFM}
  99.  
  100. { TTDM47X }
  101.  
  102. procedure TTDM47X.DefinePropertyPages(DefinePropertyPage: TDefinePropertyPage);
  103. begin
  104.   { Define property pages here.  Property pages are defined by calling
  105.     DefinePropertyPage with the class id of the page.  For example,
  106.       DefinePropertyPage(Class_TDM47XPage); }
  107. end;
  108.  
  109. procedure TTDM47X.EventSinkChanged(const EventSink: IUnknown);
  110. begin
  111.   FEvents := EventSink as ITDM47XEvents;
  112. end;
  113.  
  114. procedure TTDM47X.Initialize;
  115. begin
  116.   inherited Initialize;
  117.   OnActivate := ActivateEvent;
  118.   OnClick := ClickEvent;
  119.   OnCreate := CreateEvent;
  120.   OnDblClick := DblClickEvent;
  121.   OnDeactivate := DeactivateEvent;
  122.   OnDestroy := DestroyEvent;
  123.   OnKeyPress := KeyPressEvent;
  124.   OnPaint := PaintEvent;
  125. end;
  126.  
  127. function TTDM47X.Get_Active: WordBool;
  128. begin
  129.   Result := Active;
  130. end;
  131.  
  132. function TTDM47X.Get_AutoScroll: WordBool;
  133. begin
  134.   Result := AutoScroll;
  135. end;
  136.  
  137. function TTDM47X.Get_AutoSize: WordBool;
  138. begin
  139.   Result := AutoSize;
  140. end;
  141.  
  142. function TTDM47X.Get_AxBorderStyle: TxActiveFormBorderStyle;
  143. begin
  144.   Result := Ord(AxBorderStyle);
  145. end;
  146.  
  147. function TTDM47X.Get_BiDiMode: TxBiDiMode;
  148. begin
  149.   Result := Ord(BiDiMode);
  150. end;
  151.  
  152. function TTDM47X.Get_Caption: WideString;
  153. begin
  154.   Result := WideString(Caption);
  155. end;
  156.  
  157. function TTDM47X.Get_Color: OLE_COLOR;
  158. begin
  159.   Result := OLE_COLOR(Color);
  160. end;
  161.  
  162. function TTDM47X.Get_Cursor: Smallint;
  163. begin
  164.   Result := Smallint(Cursor);
  165. end;
  166.  
  167. function TTDM47X.Get_DoubleBuffered: WordBool;
  168. begin
  169.   Result := DoubleBuffered;
  170. end;
  171.  
  172. function TTDM47X.Get_DropTarget: WordBool;
  173. begin
  174.   Result := DropTarget;
  175. end;
  176.  
  177. function TTDM47X.Get_Enabled: WordBool;
  178. begin
  179.   Result := Enabled;
  180. end;
  181.  
  182. function TTDM47X.Get_Font: IFontDisp;
  183. begin
  184.   GetOleFont(Font, Result);
  185. end;
  186.  
  187. function TTDM47X.Get_HelpFile: WideString;
  188. begin
  189.   Result := WideString(HelpFile);
  190. end;
  191.  
  192. function TTDM47X.Get_KeyPreview: WordBool;
  193. begin
  194.   Result := KeyPreview;
  195. end;
  196.  
  197. function TTDM47X.Get_PixelsPerInch: Integer;
  198. begin
  199.   Result := PixelsPerInch;
  200. end;
  201.  
  202. function TTDM47X.Get_PrintScale: TxPrintScale;
  203. begin
  204.   Result := Ord(PrintScale);
  205. end;
  206.  
  207. function TTDM47X.Get_Scaled: WordBool;
  208. begin
  209.   Result := Scaled;
  210. end;
  211.  
  212. function TTDM47X.Get_Visible: WordBool;
  213. begin
  214.   Result := Visible;
  215. end;
  216.  
  217. procedure TTDM47X._Set_Font(const Value: IFontDisp);
  218. begin
  219.   SetOleFont(Font, Value);
  220. end;
  221.  
  222. procedure TTDM47X.Set_AutoScroll(Value: WordBool);
  223. begin
  224.   AutoScroll := Value;
  225. end;
  226.  
  227. procedure TTDM47X.Set_AutoSize(Value: WordBool);
  228. begin
  229.   AutoSize := Value;
  230. end;
  231.  
  232. procedure TTDM47X.Set_AxBorderStyle(Value: TxActiveFormBorderStyle);
  233. begin
  234.   AxBorderStyle := TActiveFormBorderStyle(Value);
  235. end;
  236.  
  237. procedure TTDM47X.Set_BiDiMode(Value: TxBiDiMode);
  238. begin
  239.   BiDiMode := TBiDiMode(Value);
  240. end;
  241.  
  242. procedure TTDM47X.Set_Caption(const Value: WideString);
  243. begin
  244.   Caption := TCaption(Value);
  245. end;
  246.  
  247. procedure TTDM47X.Set_Color(Value: OLE_COLOR);
  248. begin
  249.   Color := TColor(Value);
  250. end;
  251.  
  252. procedure TTDM47X.Set_Cursor(Value: Smallint);
  253. begin
  254.   Cursor := TCursor(Value);
  255. end;
  256.  
  257. procedure TTDM47X.Set_DoubleBuffered(Value: WordBool);
  258. begin
  259.   DoubleBuffered := Value;
  260. end;
  261.  
  262. procedure TTDM47X.Set_DropTarget(Value: WordBool);
  263. begin
  264.   DropTarget := Value;
  265. end;
  266.  
  267. procedure TTDM47X.Set_Enabled(Value: WordBool);
  268. begin
  269.   Enabled := Value;
  270. end;
  271.  
  272. procedure TTDM47X.Set_Font(var Value: IFontDisp);
  273. begin
  274.   SetOleFont(Font, Value);
  275. end;
  276.  
  277. procedure TTDM47X.Set_HelpFile(const Value: WideString);
  278. begin
  279.   HelpFile := String(Value);
  280. end;
  281.  
  282. procedure TTDM47X.Set_KeyPreview(Value: WordBool);
  283. begin
  284.   KeyPreview := Value;
  285. end;
  286.  
  287. procedure TTDM47X.Set_PixelsPerInch(Value: Integer);
  288. begin
  289.   PixelsPerInch := Value;
  290. end;
  291.  
  292. procedure TTDM47X.Set_PrintScale(Value: TxPrintScale);
  293. begin
  294.   PrintScale := TPrintScale(Value);
  295. end;
  296.  
  297. procedure TTDM47X.Set_Scaled(Value: WordBool);
  298. begin
  299.   Scaled := Value;
  300. end;
  301.  
  302. procedure TTDM47X.Set_Visible(Value: WordBool);
  303. begin
  304.   Visible := Value;
  305. end;
  306.  
  307. procedure TTDM47X.ActivateEvent(Sender: TObject);
  308. begin
  309.   if FEvents <> nil then FEvents.OnActivate;
  310. end;
  311.  
  312. procedure TTDM47X.ClickEvent(Sender: TObject);
  313. begin
  314.   if FEvents <> nil then FEvents.OnClick;
  315. end;
  316.  
  317. procedure TTDM47X.CreateEvent(Sender: TObject);
  318. begin
  319.   if FEvents <> nil then FEvents.OnCreate;
  320. end;
  321.  
  322. procedure TTDM47X.DblClickEvent(Sender: TObject);
  323. begin
  324.   if FEvents <> nil then FEvents.OnDblClick;
  325. end;
  326.  
  327. procedure TTDM47X.DeactivateEvent(Sender: TObject);
  328. begin
  329.   if FEvents <> nil then FEvents.OnDeactivate;
  330. end;
  331.  
  332. procedure TTDM47X.DestroyEvent(Sender: TObject);
  333. begin
  334.   if FEvents <> nil then FEvents.OnDestroy;
  335. end;
  336.  
  337. procedure TTDM47X.KeyPressEvent(Sender: TObject; var Key: Char);
  338. var
  339.   TempKey: Smallint;
  340. begin
  341.   TempKey := Smallint(Key);
  342.   if FEvents <> nil then FEvents.OnKeyPress(TempKey);
  343.   Key := Char(TempKey);
  344. end;
  345.  
  346. procedure TTDM47X.PaintEvent(Sender: TObject);
  347. begin
  348.   if FEvents <> nil then FEvents.OnPaint;
  349. end;
  350.  
  351. initialization
  352.   TActiveFormFactory.Create(
  353.     ComServer,
  354.     TActiveFormControl,
  355.     TTDM47X,
  356.     Class_TDM47X,
  357.     1,
  358.     '',
  359.     OLEMISC_SIMPLEFRAME or OLEMISC_ACTSLIKELABEL,
  360.     tmApartment);
  361. end.
  362.